//
// Created by HP on 2024/4/15.
//

#ifndef AURORA_ST_AURORA_MOTOR_H
#define AURORA_ST_AURORA_MOTOR_H

#include "common_inc.h"
#include "aurora_foc.h"





class Aurora_Motor{
//    typedef enum Ctrl_State{
//        IDLE = 0,
//        LOPEN_MODE,
//        ROPEN_MODE,
//        LROPEN_MODE,
//
//
//        LI_MODE,
//        RI_MODE,
//        LRI_MODE,
//
//        LSPEED_MODE,
//        RSPEED_MODE,
//        LRSPEED_MODE,
//
//        LPOSITION_MODE,
//        RPOSITION_MODE,
//        LRPOSITION_MODE,
//
// }Ctrl_State;
    typedef enum Ctrl_State{
        IDLE = 0,
        Motor_OPEN_MODE,
        Motor_I_MODE,
        Motor_SPEED_MODE,
        Motor_POSITION_MODE,
    }Ctrl_State;
typedef struct Motor_State{
    Ctrl_State ctrlState;
}Motor_State;

public:
    Aurora_Motor();

    void add_AS5047_Driver(AS5047_Driver *as5047_L,AS5047_Driver *as5047_R);


    void main_deal(uint8_t enable_L,uint8_t enable_R,uint32_t data1,uint32_t data2,uint32_t data3,uint32_t data4);
    void open_deal();

    void calibration_angle_pole_pair(uint8_t enable_L,uint8_t enable_R); //校准电机 和 极对数
    void enable_current_sampling(uint8_t enable_L,uint8_t enable_R); //使能 电流采样

    void start_pwm();
public:
    void dealmsgEvent_from_UI(struct Aurora_UI2FOC_MSG *ui2foc_msg_p);
    void dealmsgEvent_from_COMM(struct Aurora_COMM2FOC_MSG *comm2foc_msg_p);
private:
    Aurora_FOC focL, focR;

    Motor_State Lstate;
    Motor_State Rstate;

    uint16_t Send_Detail_cnt;  //多少次发送一次
    uint8_t Send_Detail_Flag;  //发送电机详细信息
};

#endif //AURORA_ST_AURORA_MOTOR_H
